﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XAPI.Data;
using XAPI.Domain;

namespace TinCan.LRS.Web.Components
{
    public class InMemoryStorage : IRepository
    {
        List<Statement> statementQueue;

        public InMemoryStorage()
        {
            statementQueue = System.Web.HttpContext.Current.Application["statementQueue"] as List<Statement>;
            if (statementQueue == null)
            {
                statementQueue = new List<Statement>();
            }
        }
        public void StoreStatement(Statement statement)
        {
            statementQueue.Add(statement);
            System.Web.HttpContext.Current.Application["statementQueue"] = statementQueue;
        }


        public Statement GetStatement(Guid statementID)
        {
            return statementQueue.FirstOrDefault(i => i.id == statementID);
        }


        public IEnumerable<Statement> GetAllStatements()
        {
            return statementQueue;
        }

        public IQueryable<T> Query<T>(System.Linq.Expressions.Expression<Func<T, bool>> filter = null) where T : class
        {
            throw new NotImplementedException();
        }

        public T SingleOrDefault<T>(System.Linq.Expressions.Expression<Func<T, bool>> predicate) where T : class
        {
            throw new NotImplementedException();
        }

        public void Insert<T>(T entity) where T : class
        {
            throw new NotImplementedException();
        }

        public void Update<T>(T entity) where T : class
        {
            throw new NotImplementedException();
        }

        public void Delete<T>(T entity) where T : class
        {
            throw new NotImplementedException();
        }


        public void AddOrModify<T>(T entity, string key) where T : class, IEntity
        {
            throw new NotImplementedException();
        }
    }
}